
import random
from playwright.sync_api import sync_playwright
import subprocess
import datetime
import time


class ContextPagePool:
    def __init__(self):
        a = {}
        a['data']=1
        a['in_use']=False
        self.pool = []
        self.pool.append(a)
        b = {}
        b['data']=1
        b['in_use']=False
        self.pool.append(b)

    def acquire(self):
        for item in self.pool:
            if not item["in_use"]:
                item["in_use"] = True
                return item

    def release(self, item):
        item["in_use"] = False

    def print_pool(self):
        for item in self.pool:
            print(item['data'], ' ', item['in_use'])



def fun():
    playwright = sync_playwright().start()
    self.browser = self.playwright.chromium.launch(
        headless=False,
        args=["--no-sandbox",
            "--disable-blink-features=AutomationControlled",
            "--disable-dev-shm-usage",
            "--disable-gpu"
        ]
    )

def extract_first_column_from_file(file_path):
    """
    从文本文件读取内容，提取每行第一个逗号分隔的元素
    :param file_path: 文件路径
    :return: 包含每行第一个元素的列表
    """
    result = []
    with open(file_path, 'r', encoding='utf-8') as file:
        for line in file:
            line = line.strip()  # 去除首尾空白字符
            if line:  # 跳过空行
                first_item = line.split(',', 1)[0].strip()
                result.append(first_item)
    return result



def fun1():
    a = ['https://www.xiachufang.com/recipe/106477587/', 'https://www.xiachufang.com/recipe/106837578/', 'https://www.xiachufang.com/recipe/106789618/', 'https://www.xiachufang.com/recipe/104039047/', 'https://www.xiachufang.com/recipe/106147494/', 'https://www.xiachufang.com/recipe/107233878/', 'https://www.xiachufang.com/recipe/102186975/', 'https://www.xiachufang.com/recipe/103783402/', 'https://www.xiachufang.com/recipe/106898626/', 'https://www.xiachufang.com/recipe/104017109/', 'https://www.xiachufang.com/recipe/106182040/', 'https://www.xiachufang.com/recipe/107015736/', 'https://www.xiachufang.com/recipe/106455270/', 'https://www.xiachufang.com/recipe/106447595/', 'https://www.xiachufang.com/recipe/106546324/', 'https://www.xiachufang.com/recipe/106101593/', 'https://www.xiachufang.com/recipe/106508854/', 'https://www.xiachufang.com/recipe/104476482/', 'https://www.xiachufang.com/recipe/106807197/', 'https://www.xiachufang.com/recipe/107044017/', 'https://www.xiachufang.com/recipe/107281227/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/103216820/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106990361/', 'https://www.xiachufang.com/recipe/106983814/', 'https://www.xiachufang.com/recipe/106041684/', 'https://www.xiachufang.com/recipe/104675810/', 'https://www.xiachufang.com/recipe/105830747/', 'https://www.xiachufang.com/recipe/104240521/', 'https://www.xiachufang.com/recipe/103036373/', 'https://www.xiachufang.com/recipe/106579400/', 'https://www.xiachufang.com/recipe/103951278/', 'https://www.xiachufang.com/recipe/103871555/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107106795/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106845231/', 'https://www.xiachufang.com/recipe/106932865/', 'https://www.xiachufang.com/recipe/106565308/', 'https://www.xiachufang.com/recipe/106838722/', 'https://www.xiachufang.com/recipe/100125819/', 'https://www.xiachufang.com/recipe/107347191/', 'https://www.xiachufang.com/recipe/106532110/', 'https://www.xiachufang.com/recipe/106816200/', 'https://www.xiachufang.com/recipe/106522263/', 'https://www.xiachufang.com/recipe/105851345/', 'https://www.xiachufang.com/recipe/107114615/', 'https://www.xiachufang.com/recipe/107051351/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/104773602/', 'https://www.xiachufang.com/recipe/107299012/', 'https://www.xiachufang.com/recipe/107500175/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106992845/', 'https://www.xiachufang.com/recipe/103468406/', 'https://www.xiachufang.com/recipe/107001712/', 'https://www.xiachufang.com/recipe/107429158/', 'https://www.xiachufang.com/recipe/107167074/', 'https://www.xiachufang.com/recipe/106662366/', 'https://www.xiachufang.com/recipe/106809208/', 'https://www.xiachufang.com/recipe/103704043/', 'https://www.xiachufang.com/recipe/104481982/', 'https://www.xiachufang.com/recipe/107545349/', 'https://www.xiachufang.com/recipe/107519353/', 'https://www.xiachufang.com/recipe/101857733/', 'https://www.xiachufang.com/recipe/106185481/', 'https://www.xiachufang.com/recipe/102911412/', 'https://www.xiachufang.com/recipe/106658033/', 'https://www.xiachufang.com/recipe/107363906/', 'https://www.xiachufang.com/recipe/106528569/', 'https://www.xiachufang.com/recipe/101890797/', 'https://www.xiachufang.com/recipe/105947919/', 'https://www.xiachufang.com/recipe/107258529/', 'https://www.xiachufang.com/recipe/107347069/', 'https://www.xiachufang.com/recipe/107286680/', 'https://www.xiachufang.com/recipe/104389529/', 'https://www.xiachufang.com/recipe/107523230/', 'https://www.xiachufang.com/recipe/104684031/', 'https://www.xiachufang.com/recipe/107242816/', 'https://www.xiachufang.com/recipe/103894902/', 'https://www.xiachufang.com/recipe/107237948/', 'https://www.xiachufang.com/recipe/103718800/', 'https://www.xiachufang.com/recipe/107316610/', 'https://www.xiachufang.com/recipe/106128768/', 'https://www.xiachufang.com/recipe/107382346/', 'https://www.xiachufang.com/recipe/107008579/', 'https://www.xiachufang.com/recipe/107121013/', 'https://www.xiachufang.com/recipe/106868575/', 'https://www.xiachufang.com/recipe/106901160/', 'https://www.xiachufang.com/recipe/107335965/', 'https://www.xiachufang.com/recipe/106399585/', 'https://www.xiachufang.com/recipe/107238554/', 'https://www.xiachufang.com/recipe/107179095/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106481057/', 'https://www.xiachufang.com/recipe/107262573/', 'https://www.xiachufang.com/recipe/107468296/', 'https://www.xiachufang.com/recipe/103933064/', 'https://www.xiachufang.com/recipe/104569835/', 'https://www.xiachufang.com/recipe/107218639/', 'https://www.xiachufang.com/recipe/106966986/', 'https://www.xiachufang.com/recipe/107044113/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106679300/', 'https://www.xiachufang.com/recipe/107204777/', 'https://www.xiachufang.com/recipe/104255336/', 'https://www.xiachufang.com/recipe/106950879/', 'https://www.xiachufang.com/recipe/107494887/', 'https://www.xiachufang.com/recipe/107447045/', 'https://www.xiachufang.com/recipe/105886044/', 'https://www.xiachufang.com/recipe/104593714/', 'https://www.xiachufang.com/recipe/107331250/', 'https://www.xiachufang.com/recipe/106952379/', 'https://www.xiachufang.com/recipe/102428610/', 'https://www.xiachufang.com/recipe/106591062/', 'https://www.xiachufang.com/recipe/107359007/', 'https://www.xiachufang.com/recipe/107226147/', 'https://www.xiachufang.com/recipe/105949154/', 'https://www.xiachufang.com/recipe/104119867/', 'https://www.xiachufang.com/recipe/107194867/', 'https://www.xiachufang.com/recipe/105910452/', 'https://www.xiachufang.com/recipe/106783392/', 'https://www.xiachufang.com/recipe/107161020/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106872580/', 'https://www.xiachufang.com/recipe/106181674/', 'https://www.xiachufang.com/recipe/103705544/', 'https://www.xiachufang.com/recipe/107570051/', 'https://www.xiachufang.com/recipe/106785543/', 'https://www.xiachufang.com/recipe/106138353/', 'https://www.xiachufang.com/recipe/106831344/', 'https://www.xiachufang.com/recipe/106552466/', 'https://www.xiachufang.com/recipe/107359870/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/103770792/', 'https://www.xiachufang.com/recipe/107507346/', 'https://www.xiachufang.com/recipe/107035580/', 'https://www.xiachufang.com/recipe/107340875/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107366268/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107446069/', 'https://www.xiachufang.com/recipe/107556736/', 'https://www.xiachufang.com/recipe/107295891/', 'https://www.xiachufang.com/recipe/105819556/', 'https://www.xiachufang.com/recipe/101802510/', 'https://www.xiachufang.com/recipe/107555107/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106806238/', 'https://www.xiachufang.com/recipe/106726998/', 'https://www.xiachufang.com/recipe/107475697/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106909640/', 'https://www.xiachufang.com/recipe/107023314/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107002102/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107341125/', 'https://www.xiachufang.com/recipe/107104308/', 'https://www.xiachufang.com/recipe/103709344/', 'https://www.xiachufang.com/recipe/107340647/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107363794/', 'https://www.xiachufang.com/recipe/107577769/', 'https://www.xiachufang.com/recipe/106766595/', 'https://www.xiachufang.com/recipe/107567957/', 'https://www.xiachufang.com/recipe/107568946/', 'https://www.xiachufang.com/recipe/107021537/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107168269/', 'https://www.xiachufang.com/recipe/107223892/', 'https://www.xiachufang.com/recipe/107475810/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107422940/', 'https://www.xiachufang.com/recipe/107553938/', 'https://www.xiachufang.com/recipe/107465959/', 'https://www.xiachufang.com/recipe/107569367/', 'https://www.xiachufang.com/recipe/107540939/', 'https://www.xiachufang.com/recipe/107477826/', 'https://www.xiachufang.com/recipe/107196111/', 'https://www.xiachufang.com/recipe/107314483/', 'https://www.xiachufang.com/recipe/107467343/', 'https://www.xiachufang.com/recipe/107507853/', 'https://www.xiachufang.com/recipe/107533659/', 'https://www.xiachufang.com/recipe/107466720/', 'https://www.xiachufang.com/recipe/107417938/', 'https://www.xiachufang.com/recipe/107566163/', 'https://www.xiachufang.com/recipe/107539806/', 'https://www.xiachufang.com/recipe/107486199/', 'https://www.xiachufang.com/recipe/107488404/', 'https://www.xiachufang.com/recipe/107406014/', 'https://www.xiachufang.com/recipe/107470684/', 'https://www.xiachufang.com/recipe/107217885/', 'https://www.xiachufang.com/recipe/107514795/', 'https://www.xiachufang.com/recipe/107211969/', 'https://www.xiachufang.com/recipe/107523008/', 'https://www.xiachufang.com/recipe/107333000/', 'https://www.xiachufang.com/recipe/107410743/', 'https://www.xiachufang.com/recipe/106966048/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107214696/', 'https://www.xiachufang.com/recipe/107502118/', 'https://www.xiachufang.com/recipe/106797749/', 'https://www.xiachufang.com/recipe/107472601/', 'https://www.xiachufang.com/recipe/107479539/', 'https://www.xiachufang.com/recipe/107268181/', 'https://www.xiachufang.com/recipe/107507666/', 'https://www.xiachufang.com/recipe/107456335/', 'https://www.xiachufang.com/recipe/107565691/', 'https://www.xiachufang.com/recipe/107017217/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107446463/', 'https://www.xiachufang.com/recipe/107466637/', 'https://www.xiachufang.com/recipe/107572714/', 'https://www.xiachufang.com/recipe/107411782/', 'https://www.xiachufang.com/recipe/107485006/', 'https://www.xiachufang.com/recipe/107454664/', 'https://www.xiachufang.com/recipe/107487709/', 'https://www.xiachufang.com/recipe/107428409/', 'https://www.xiachufang.com/recipe/107498719/', 'https://www.xiachufang.com/recipe/107566755/', 'https://www.xiachufang.com/recipe/107362673/', 'https://www.xiachufang.com/recipe/107203907/', 'https://www.xiachufang.com/recipe/107475871/', 'https://www.xiachufang.com/recipe/107548397/', 'https://www.xiachufang.com/recipe/107469877/', 'https://www.xiachufang.com/recipe/107511201/', 'https://www.xiachufang.com/recipe/107519881/', 'https://www.xiachufang.com/recipe/107518676/', 'https://www.xiachufang.com/recipe/107541301/', 'https://www.xiachufang.com/recipe/107468858/', 'https://www.xiachufang.com/recipe/107485963/', 'https://www.xiachufang.com/recipe/107476377/', 'https://www.xiachufang.com/recipe/107542232/', 'https://www.xiachufang.com/recipe/107401538/', 'https://www.xiachufang.com/recipe/107478080/', 'https://www.xiachufang.com/recipe/107148423/', '《番茄红焖大虾》', 'https://www.xiachufang.com/recipe/107558979/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107438001/', 'https://www.xiachufang.com/recipe/107578195/', 'https://www.xiachufang.com/recipe/107444495/', 'https://www.xiachufang.com/recipe/107468463/', 'https://www.xiachufang.com/recipe/107561824/', '卤牛肉', '芦笋虾仁口蘑', 'https://www.xiachufang.com/recipe/107527708/', 'https://www.xiachufang.com/recipe/107477562/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107494138/', 'https://www.xiachufang.com/recipe/107502934/', 'https://www.xiachufang.com/recipe/107301710/', 'https://www.xiachufang.com/recipe/107268586/', 'https://www.xiachufang.com/recipe/107429843/', 'https://www.xiachufang.com/recipe/107324305/', 'https://www.xiachufang.com/recipe/106918186/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107463781/', 'https://www.xiachufang.com/recipe/107395117/', 'https://www.xiachufang.com/recipe/106967568/', 'https://www.xiachufang.com/recipe/107396927/', 'https://www.xiachufang.com/recipe/107451303/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107410908/', 'https://www.xiachufang.com/recipe/107509242/', 'https://www.xiachufang.com/recipe/107470702/', 'https://www.xiachufang.com/recipe/107473052/', 'https://www.xiachufang.com/recipe/107550688/', 'https://www.xiachufang.com/recipe/107466805/', 'https://www.xiachufang.com/recipe/107490443/', 'https://www.xiachufang.com/recipe/107415748/', 'https://www.xiachufang.com/recipe/107471335/', 'https://www.xiachufang.com/recipe/107277402/', 'https://www.xiachufang.com/recipe/107438859/', 'https://www.xiachufang.com/recipe/107487986/', 'https://www.xiachufang.com/recipe/107436466/', 'https://www.xiachufang.com/recipe/107398229/', 'https://www.xiachufang.com/recipe/107484854/', 'https://www.xiachufang.com/recipe/107320696/', 'https://www.xiachufang.com/recipe/107194072/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107370392/', 'https://www.xiachufang.com/recipe/107404202/', 'https://www.xiachufang.com/recipe/107467313/', 'https://www.xiachufang.com/recipe/107421387/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107266331/', 'https://www.xiachufang.com/recipe/107145449/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107363255/', 'https://www.xiachufang.com/recipe/107376802/', 'https://www.xiachufang.com/recipe/107187344/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107359758/', 'https://www.xiachufang.com/recipe/107413099/', 'https://www.xiachufang.com/recipe/107411434/', 'https://www.xiachufang.com/recipe/107434118/', 'https://www.xiachufang.com/recipe/107489233/', 'https://www.xiachufang.com/recipe/107370129/', 'https://www.xiachufang.com/recipe/107487033/', 'https://www.xiachufang.com/recipe/107406323/', 'https://www.xiachufang.com/recipe/107342039/', 'https://www.xiachufang.com/recipe/106155782/', 'https://www.xiachufang.com/recipe/107243508/', 'https://www.xiachufang.com/recipe/107358979/', 'https://www.xiachufang.com/recipe/107345316/', 'https://www.xiachufang.com/recipe/107003930/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107498817/', 'https://www.xiachufang.com/recipe/107418963/', 'https://www.xiachufang.com/recipe/107373891/', 'https://www.xiachufang.com/recipe/107340535/', 'https://www.xiachufang.com/recipe/107237293/', 'https://www.xiachufang.com/recipe/107294252/', 'https://www.xiachufang.com/recipe/107268574/', 'https://www.xiachufang.com/recipe/106901875/', 'https://www.xiachufang.com/recipe/106981197/', 'https://www.xiachufang.com/recipe/107404466/', 'https://www.xiachufang.com/recipe/107268365/', 'https://www.xiachufang.com/recipe/107379916/', 'https://www.xiachufang.com/recipe/107403138/', 'https://www.xiachufang.com/recipe/107326484/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107005463/', 'https://www.xiachufang.com/recipe/106847168/', 'https://www.xiachufang.com/recipe/107366314/', 'https://www.xiachufang.com/recipe/107323707/', 'https://www.xiachufang.com/recipe/107017506/', 'https://www.xiachufang.com/recipe/107288595/', 'https://www.xiachufang.com/recipe/106606331/', 'https://www.xiachufang.com/recipe/107362461/', 'https://www.xiachufang.com/recipe/107227029/', 'https://www.xiachufang.com/recipe/107228156/', 'https://www.xiachufang.com/recipe/107353444/', 'https://www.xiachufang.com/recipe/107267804/', 'https://www.xiachufang.com/recipe/106279448/', 'https://www.xiachufang.com/recipe/107269085/', 'https://www.xiachufang.com/recipe/107223130/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106853593/', 'https://www.xiachufang.com/recipe/107334102/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107357140/', 'https://www.xiachufang.com/recipe/107241934/', 'https://www.xiachufang.com/recipe/107339660/', 'https://www.xiachufang.com/recipe/106850484/', 'https://www.xiachufang.com/recipe/107209815/', 'https://www.xiachufang.com/recipe/107284145/', 'https://www.xiachufang.com/recipe/106748835/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107194611/', 'https://www.xiachufang.com/recipe/106101844/', 'https://www.xiachufang.com/recipe/107170672/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107021034/', 'https://www.xiachufang.com/recipe/107115355/', 'https://www.xiachufang.com/recipe/107071238/', 'https://www.xiachufang.com/recipe/107027581/', 'https://www.xiachufang.com/recipe/106808361/', 'https://www.xiachufang.com/recipe/105860683/', 'https://www.xiachufang.com/recipe/104757342/', 'https://www.xiachufang.com/recipe/107474726/', 'https://www.xiachufang.com/recipe/106728793/', 'https://www.xiachufang.com/recipe/106750566/', 'https://www.xiachufang.com/recipe/107324637/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/104188280/', 'https://www.xiachufang.com/recipe/106651552/', 'https://www.xiachufang.com/recipe/107578070/', 'https://www.xiachufang.com/recipe/103643954/', 'https://www.xiachufang.com/recipe/106910816/', 'https://www.xiachufang.com/recipe/105889735/', 'https://www.xiachufang.com/recipe/103898126/', 'https://www.xiachufang.com/recipe/106034296/', 'https://www.xiachufang.com/recipe/106137567/', 'https://www.xiachufang.com/recipe/107567979/', 'https://www.xiachufang.com/recipe/104045220/', 'https://www.xiachufang.com/recipe/106473320/', 'https://www.xiachufang.com/recipe/106556251/', 'https://www.xiachufang.com/recipe/104395177/', 'https://www.xiachufang.com/recipe/104565483/', 'https://www.xiachufang.com/recipe/106528929/', 'https://www.xiachufang.com/recipe/107336825/', 'https://www.xiachufang.com/recipe/104201204/', 'https://www.xiachufang.com/recipe/106018479/', '大师菜谱', 'https://www.xiachufang.com/recipe/107372592/', 'https://www.xiachufang.com/recipe/104431603/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/104309261/', 'https://www.xiachufang.com/recipe/107535934/', 'https://www.xiachufang.com/recipe/106598677/', 'https://www.xiachufang.com/recipe/106187332/', 'https://www.xiachufang.com/recipe/107405452/', 'https://www.xiachufang.com/recipe/104780258/', 'https://www.xiachufang.com/recipe/106740447/', 'https://www.xiachufang.com/recipe/107249566/', 'https://www.xiachufang.com/recipe/107157847/', 'https://www.xiachufang.com/recipe/107478163/', 'https://www.xiachufang.com/recipe/107292226/', 'https://www.xiachufang.com/recipe/107356827/', 'https://www.xiachufang.com/recipe/107359349/', 'https://www.xiachufang.com/recipe/107294662/', 'https://www.xiachufang.com/recipe/104067722/', 'https://www.xiachufang.com/recipe/107459300/', 'https://www.xiachufang.com/recipe/107183272/', 'https://www.xiachufang.com/recipe/107405453/', 'https://www.xiachufang.com/recipe/107405454/', 'https://www.xiachufang.com/recipe/103952912/', 'https://www.xiachufang.com/recipe/106898825/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107297799/', 'https://www.xiachufang.com/recipe/107421414/', 'https://www.xiachufang.com/recipe/107041857/', 'https://www.xiachufang.com/recipe/107192594/', 'https://www.xiachufang.com/recipe/107113200/', 'https://www.xiachufang.com/recipe/107426804/', 'https://www.xiachufang.com/recipe/107341784/', 'https://www.xiachufang.com/recipe/107199525/', 'https://www.xiachufang.com/recipe/106985487/', 'https://www.xiachufang.com/recipe/107326415/', 'https://www.xiachufang.com/recipe/107202673/', 'https://www.xiachufang.com/recipe/107411682/', 'https://www.xiachufang.com/recipe/106660752/', 'https://www.xiachufang.com/recipe/107219449/', 'https://www.xiachufang.com/recipe/106950348/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107201928/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107276451/', 'https://www.xiachufang.com/recipe/107267672/', 'https://www.xiachufang.com/recipe/106576403/', 'https://www.xiachufang.com/recipe/107337954/', 'https://www.xiachufang.com/recipe/106945723/', 'https://www.xiachufang.com/recipe/107037947/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/107392324/', 'https://www.xiachufang.com/recipe/106065749/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/104065841/', 'https://www.xiachufang.com/recipe/104779029/', 'https://www.xiachufang.com/recipe/104433198/', 'https://www.xiachufang.com/recipe/104451897/', 'https://www.xiachufang.com/recipe/104494503/', 'https://www.xiachufang.com/recipe/107463643/', 'https://www.xiachufang.com/recipe/106022510/', 'https://www.xiachufang.com/recipe/105957722/', 'https://www.xiachufang.com/recipe/107144221/', 'https://www.xiachufang.com/recipe/106106072/', 'https://www.xiachufang.com/recipe/106934753/', 'https://www.xiachufang.com/recipe/107058604/', 'https://www.xiachufang.com/recipe/106656316/', 'https://www.xiachufang.com/recipe/106997575/', 'https://www.xiachufang.com/recipe/106080576/', 'https://www.xiachufang.com/recipe/102989061/?recipe_type=1&page_scene=6', 'https://www.xiachufang.com/recipe/106955842/']

    for item in a:
        try:
            item.split('/')[-2]
        except:
            import pdb
            pdb.set_trace()
            print(item)


def move_window(window_title, x, y, width, height):
    """使用 xdotool 移动窗口"""
    cmd = f"xdotool search --name '{window_title}' windowmove {x} {y} windowsize {width} {height}"
    subprocess.run(cmd, shell=True)

def move_window_by_pid(pid, x, y):
    # 查找该 PID 下的所有窗口
    cmd = f"xdotool search --pid {pid}"
    window_ids = subprocess.check_output(cmd, shell=True).decode().split()
    
    # 移动所有关联窗口（通常第一个是主窗口）
    for wid in window_ids:
        subprocess.run(f"xdotool windowmove {wid} {x} {y}", shell=True)

def fun2():

    p = sync_playwright().start()

    browser = p.chromium.launch(headless=False)

    context1 = browser.new_context(
        viewport={"width": 800, "height": 500},
        screen={"width": 800, "height": 500, "x": 0, "y": 0}  # 模拟屏幕位置
    )
    page1 = context1.new_page()

    context2 = browser.new_context(
        viewport={"width": 800, "height": 500},
        screen={"width": 800, "height": 500, "x": 800, "y": 500}  # 模拟屏幕位置
    )
    page2 = context2.new_page()

    page1.goto("https://www.baidu.com")
    # page1.evaluate("window.moveTo(0, 0)")
    print(page1.title()) # 打印网页标题栏
    
    page2.goto("https://www.byhy.net/cdn2/files/selenium/stock1.html")
    # page2.evaluate("window.moveTo(500, 250)")
    print(page2.title()) # 打印网页标题栏
    browser = page2.context.browser  # 先获取 Browser 对象
    ws_endpoint = browser._impl_obj._connection._ws_endpoint
    page2Pid = int(ws_endpoint.split('-')[-1].split('.')[0])
    move_window_by_pid(page2Pid, 500, 250)




    input('3....')
    # 关闭浏览器
    page1.close()
    page2.close()
    context1.close()
    context2.close()
    browser.close()
    # 关闭 playwright driver 进程
    p.stop()


def fun3():
    a = 4
    if a > 3:
        print('a>3')
    elif a<8:
        print('a<8')
    elif a>2:
        print('a>2')
    else:
        print('none')


def main():
    # result = extract_first_column_from_file('/media/zhaosl/T7/菜谱/caipudata/CSVDetail/1000426.csv')
    # print('result: ', len(result))
    # set_result = set(result)
    # print('set_result: ', len(set_result))
    # fun2()

    # 使用示例
    # time_print("process started...")
    # time_print("value is", 42)

    #
    # examPool = ContextPagePool()
    # a = examPool.acquire()
    # time.sleep(2)
    # examPool.print_pool()

    # examPool.release(a)
    # time.sleep(2)
    # examPool.print_pool()

    fun3()

    

if __name__ == "__main__":
    main()